package com.lzy.wzy.model;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

public class UserBean implements UserDetails {

    private String username;
    private String password;
    private List<GrantedAuthority> authorities;
    private String userUuid;
    private int userStatus;

    public UserBean() {
    }

    public UserBean(String username, String password, String userUuid, List<GrantedAuthority> authorities,int userStatus) {
        this.username = username;
        this.password = password;
        this.userUuid = userUuid;
        this.authorities = authorities;
        this.userStatus= userStatus;
    }

    @Override
    public int hashCode() {
        return this.username.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        return this.toString().equals(obj.toString());
    }

    @Override
    public String toString() {
        return this.username;
    }

    public String getUserUuid() {
        return userUuid;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {
        return username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return this.userStatus == 0;
    }
}
